import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '',
      name: '',
      component: () =>
        import('@/views/freely-accessible-page/components/header-footer.component.vue'),
      redirect: '/index',
      children: [
        {
          path: '/index',
          name: 'home',
          component: () => import('@/views/freely-accessible-page/blog-home.page.vue')
        },
        {
          path: '/blog/:id',
          name: 'blog-detail',
          component: () => import('@/views/freely-accessible-page/blog-detail.page.vue')
        },
        {
          path: '/leave-message',
          name: 'leave-message',
          component: () => import('@/views/freely-accessible-page/leave-message.page.vue')
        },
        {
          path: '/blog-classify',
          name: 'blog-classify',
          component: () => import('@/views/freely-accessible-page/blog-classify.page.vue')
        }
      ]
    },
    {
      path: '/login',
      name: 'login',
      component: () => import('@/views/user-login.page.vue')
    },

    {
      path: '/backend',
      children: [
        {
          path: 'create',
          name: 'create',
          component: () => import('@/views/backend/create-blog.page.vue')
        },
        {
          path: 'classify-manage',
          name: 'classify-manage',
          component: () => import('@/views/backend/classify-manage.page.vue')
        }
      ]
    },
    {
      path: '/404',
      name: 'not-found',
      component: () => import('@/views/freely-accessible-page/404-not-foumd.page.vue')
    },
    {
      path: '/:pathMatch(.*)*',
      redirect: '/404'
    }
  ]
})

export default router
